package com.carl.zlds.controller.web;

import com.carl.zlds.tool.common.result.Result;
import com.carl.zlds.annotation.Login;
import com.carl.zlds.controller.BaseController;
import com.carl.zlds.pojo.dto.SaveGameTagDTO;
import com.carl.zlds.pojo.vo.GameTagVO;
import com.carl.zlds.pojo.vo.GameTagWithInfoVO;
import com.carl.zlds.service.IGameTagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author carl
 */
@Slf4j
@RestController(value = "web.gameTagController")
@RequestMapping("/web/game-tag")
@Api(tags = {"管理端 - 游戏标签分类管理"})
public class GameTagController extends BaseController {

    private final IGameTagService gameTagService;

    @Autowired
    public GameTagController(IGameTagService gameTagService) {
        this.gameTagService = gameTagService;
    }

    @ApiOperation("游戏标签分类列表")
    @GetMapping(value = "/list")
    @Login(needToken = false)
    public Result<Map<String, Object>> list(@RequestParam(value = "gameId", defaultValue = "0") Long gameId) {
        List<GameTagVO> list = gameTagService.getGameTagList(gameId);
        Map<String, Object> map = new HashMap<>(1);
        map.put("list", list);
        return Result.success(map);
    }

    @ApiOperation("游戏标签分类列表(带标签)")
    @GetMapping(value = "/list-with-tag")
    @Login(needToken = false)
    public Result<Map<String, Object>> listWithTag(@RequestParam(value = "gameId", defaultValue = "0") Long gameId,
                                                   @RequestParam(value = "parentId", defaultValue = "0") Long parentId) {
        List<GameTagWithInfoVO> list = gameTagService.getGameTagListWithTag(gameId, parentId);
        Map<String, Object> map = new HashMap<>(1);
        map.put("list", list);
        return Result.success(map);
    }
}
